package com.huike.key_listener;

import android.app.Activity;
import android.app.Application;

import java.util.ArrayList;

public class BaseApplication extends Application {

    ArrayList<Activity> list = new ArrayList<>();
    public static BaseApplication instance;

    @Override
    public void onCreate() {
        super.onCreate();
    }

    //单例模式
    public static BaseApplication getInstance(){
        if(instance == null){
            instance = new BaseApplication();
        }
        return instance;
    }


    //添加
    public void addActivity(Activity activity){
        list.add(activity);
    }

    //关闭
    public void exit(){
        for(Activity activity : list){
            activity.finish();
        }
        list.clear();
    }



}
